package com.wlyuan.open.domain.source.assembler;

import com.wlyuan.basic.dto.relation.RelationRewriteDTO;
import com.wlyuan.open.dto.OpenRelationSyncDTO;
import com.wlyuan.open.dto.tenant.OpenTenantRelationSyncDTO;
import com.wlyuan.tenant.dto.tenant.TenantInviteRelationRewriteDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @author yuanzheng
 */
public class RelationAssembler {

    private static final Assembler ASSEMBLER = Mappers.getMapper(Assembler.class);

    @Mapper
    public interface Assembler {
        /**
         * 租户邀请关系
         *
         * @param source
         * @return
         */
        @Mappings({
                @Mapping(target = "tenantId", source = "id")
        })
        TenantInviteRelationRewriteDTO assembler(OpenTenantRelationSyncDTO source);

        /**
         * 承运方邀请关系
         *
         * @param source
         * @return
         */
        RelationRewriteDTO assembler(OpenRelationSyncDTO source);
    }

    public static TenantInviteRelationRewriteDTO assembler(OpenTenantRelationSyncDTO source) {
        return ASSEMBLER.assembler(source);
    }

    public static RelationRewriteDTO assembler(OpenRelationSyncDTO source) {
        return ASSEMBLER.assembler(source);
    }

}
